<?php
/**
 * Description of BackendBaseController
 *
 * @author Alexey
 */

Yii::import("application.controllers.SiteBaseController");

class BackendBaseController extends SiteBaseController {

    public $menu=array();
    public $breadcrumbs=array();
    
    public function actionLogin()
    {
        $model = new AdminLoginForm;

        // if it is ajax validation request
        if(isset($_POST['ajax']) && $_POST['ajax']==='user-login-form')
        {
            echo CActiveForm::validate($model);
            Yii::app()->end();
        }

        // collect user input data
        if(isset($_POST['AdminLoginForm']))
        {
            $model->attributes=$_POST['AdminLoginForm'];
            // validate user input and redirect to the previous page if valid
            if ($model->validate() && $model->login())
                $this->redirect(Yii::app()->params["backendUrl"]);
        }

        $this->render('login',array('model'=>$model));
    }

    public function actionLogout()
    {
        Yii::app()->user->logout();
        $this->redirect(Yii::app()->params["backendReturnUrl"]);
    }
}
?>
